/*
 * @Author: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @Date: 2025-10-03 15:30:55
 * @LastEditors: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @LastEditTime: 2025-10-10 20:18:12
 * @FilePath: /GateServer/tests/test_redis.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"../src//redis//redismgr.h"
#include <iostream>

int main() {
    // 获取 RedisMgr 单例
    auto redis =Yizhi::RedisMgr::GetInstance();
    
    // // 连接 Redis
    // if (!redis->connect("127.0.0.1", 6379)) {
    //     std::cerr << "Failed to connect to Redis" << std::endl;
    //     return 1;
    // }
    
  
    // if (!redis->Auth("zsby99924")) {
    //     std::cerr << "Authentication failed" << std::endl;
    //     return 1;
    // }
    
    // 测试基本操作
    if (redis->setvalue("test_key", "Hello Redis!")) {
        std::cout << "SET success" << std::endl;
    }
    
    std::string value;
    if (redis->getvalue("test_key", value)) {
        std::cout << "GET value: " << value << std::endl;
    }
    
    // 测试列表操作
    redis->Rpush("my_list", "item1");
    redis->Rpush("my_list", "item2");
    
    std::string popped;
    if (redis->Rpop("my_list", popped)) {
        std::cout << "RPOP value: " << popped << std::endl;
    }
    
    // 测试哈希操作
    redis->Hashset("my_hash", "field1", "value1");
    std::string hash_value = redis->HashGet("my_hash", "field1");
    std::cout << "HGET value: " << hash_value << std::endl;
    
    // 测试键是否存在
    if (redis->Existskey("test_key")) {
        std::cout << "Key exists" << std::endl;
    }
    
    return 0;
}